package com.ohuang.myapp.fragment;

import com.ohuang.baseapp.fragment.Fragment;
import com.ohuang.myapp.ResourceTable;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.*;

public class ThreeFragment extends LogFragment {

    public static ThreeFragment newInstance() {
        ThreeFragment frag = new ThreeFragment();
        return frag;
    }
    @Override
    protected int getXmlId() {
        return ResourceTable.Layout_fg_three;
    }

    ComponentContainer componentContainer;
    Text text;

    @Override
    protected void initComponent() {
        componentContainer = (ComponentContainer) findComponentById(ResourceTable.Id_layout);
        text = (Text) findComponentById(ResourceTable.Id_text);
        text.setClickedListener(v->{
            Intent intent = new Intent();

// 通过Intent中的OperationBuilder类构造operation对象，指定设备标识（空串表示当前设备）、应用包名、Ability名称
            Operation operation = new Intent.OperationBuilder()
                    .withBundleName("com.ohuang.myapp")
                    .withAbilityName("com.ohuang.myapp.MainAbility2")
                    .build();

// 把operation设置到intent中
            intent.setOperation(operation);
            getAbility().startAbility(intent);
       });


    }


}
